home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb.new / gdb-4.0 / bfd / doc / reloc.p < prev    next >
Encoding:
Text File  |  1991-09-29  |  5.4 KB  |  253 lines

  1. /* bfd_perform_relocation
  2. The relocation routine returns as a status an enumerated type:
  3. */
  4.  
  5. typedef enum bfd_reloc_status {
  6. /* No errors detected
  7. */
  8.  
  9.   bfd_reloc_ok,
  10.  
  11. /*
  12. The relocation was performed, but there was an overflow.
  13. */
  14.  
  15.   bfd_reloc_overflow,
  16.  
  17. /*
  18. The address to relocate was not within the section supplied
  19. */
  20.  
  21.   bfd_reloc_outofrange,
  22.  
  23. /*
  24. Used by special functions
  25. */
  26.  
  27.   bfd_reloc_continue,
  28.  
  29. /*
  30. Unused 
  31. */
  32.  
  33.   bfd_reloc_notsupported,
  34.  
  35. /*
  36. Unsupported relocation size requested. 
  37. */
  38.  
  39.   bfd_reloc_other,
  40.  
  41. /*
  42. The symbol to relocate against was undefined.
  43. */
  44.  
  45.   bfd_reloc_undefined,
  46.  
  47. /*
  48. The relocation was performed, but may not be ok - presently generated
  49. only when linking i960 coff files with i960 b.out symbols.
  50. */
  51.  
  52.   bfd_reloc_dangerous
  53.    }
  54.  bfd_reloc_status_enum_type;
  55.  
  56. /*
  57. */
  58.  
  59. typedef struct reloc_cache_entry 
  60. {
  61.  
  62. /*
  63. A pointer into the canonical table of pointers 
  64. */
  65.  
  66.   struct symbol_cache_entry **sym_ptr_ptr;
  67.  
  68. /*
  69. offset in section                 
  70. */
  71.  
  72.   rawdata_offset address;
  73.  
  74. /*
  75. addend for relocation value        
  76. */
  77.  
  78.   bfd_vma addend;    
  79.  
  80. /*
  81. if sym is null this is the section 
  82. */
  83.  
  84.   struct sec *section;
  85.  
  86. /*
  87. Pointer to how to perform the required relocation
  88. */
  89.  
  90.   CONST struct reloc_howto_struct *howto;
  91. } arelent;
  92.  
  93. /*
  94.  
  95.  reloc_howto_type
  96. The @code{reloc_howto_type} is a structure which contains all the
  97. information that BFD needs to know to tie up a back end's data.
  98. */
  99.  
  100. typedef CONST struct reloc_howto_struct 
  101. /* The type field has mainly a documetary use - the back end can to what
  102. it wants with it, though the normally the back end's external idea of
  103. what a reloc number would be would be stored in this field. For
  104. example, the a PC relative word relocation in a coff environment would
  105. have the type 023 - because that's what the outside world calls a
  106. R_PCRWORD reloc.
  107. */
  108.  
  109.   unsigned int type;
  110.  
  111. /*
  112. The value the final relocation is shifted right by. This drops
  113. unwanted data from the relocation. 
  114. */
  115.  
  116.   unsigned int rightshift;
  117.  
  118. /*
  119. The size of the item to be relocated - 0, is one byte, 1 is 2 bytes, 3
  120. is four bytes.
  121. */
  122.  
  123.   unsigned int size;
  124.  
  125. /*
  126. Now obsolete
  127. */
  128.  
  129.   unsigned int bitsize;
  130.  
  131. /*
  132. Notes that the relocation is relative to the location in the data
  133. section of the addend. The relocation function will subtract from the
  134. relocation value the address of the location being relocated.
  135. */
  136.  
  137.   boolean pc_relative;
  138.  
  139. /*
  140. Now obsolete
  141. */
  142.  
  143.   unsigned int bitpos;
  144.  
  145. /*
  146. Now obsolete
  147. */
  148.  
  149.   boolean absolute;
  150.  
  151. /*
  152. Causes the relocation routine to return an error if overflow is
  153. detected when relocating.
  154. */
  155.  
  156.   boolean complain_on_overflow;
  157.  
  158. /*
  159. If this field is non null, then the supplied function is called rather
  160. than the normal function. This allows really strange relocation
  161. methods to be accomodated (eg, i960 callj instructions).
  162. */
  163.  
  164.   bfd_reloc_status_enum_type (*special_function)();
  165.  
  166. /*
  167. The textual name of the relocation type.
  168. */
  169.  
  170.   char *name;
  171.  
  172. /*
  173. When performing a partial link, some formats must modify the
  174. relocations rather than the data - this flag signals this.
  175. */
  176.  
  177.   boolean partial_inplace;
  178.  
  179. /*
  180. The src_mask is used to select what parts of the read in data are to
  181. be used in the relocation sum. Eg, if this was an 8 bit bit of data
  182. which we read and relocated, this would be 0x000000ff. When we have
  183. relocs which have an addend, such as sun4 extended relocs, the value
  184. in the offset part of a relocating field is garbage so we never use
  185. it. In this case the mask would be 0x00000000.
  186. */
  187.  
  188.   bfd_word src_mask;
  189. /* The dst_mask is what parts of the instruction are replaced into the
  190. instruction. In most cases src_mask == dst_mask, except in the above
  191. special case, where dst_mask would be 0x000000ff, and src_mask would
  192. be 0x00000000.
  193. */
  194.  
  195.   bfd_word dst_mask;           
  196.  
  197. /*
  198. When some formats create PC relative instructions, they leave the
  199. value of the pc of the place being relocated in the offset slot of the
  200. instruction, so that a PC relative relocation can be made just by
  201. adding in an ordinary offset (eg sun3 a.out). Some formats leave the
  202. displacement part of an instruction empty (eg m88k bcs), this flag
  203. signals the fact.
  204. */
  205.  
  206.   boolean pcrel_offset;
  207. } reloc_howto_type;
  208.  
  209. /*
  210.  
  211.  HOWTO
  212. The HOWTO define is horrible and will go away.
  213. */
  214. #define HOWTO(C, R,S,B, P, BI, ABS, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
  215.   {(unsigned)C,R,S,B, P, BI, ABS,O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
  216.  
  217. /*
  218.  
  219.  reloc_chain
  220. */
  221. typedef unsigned char bfd_byte;
  222.  
  223. typedef struct relent_chain {
  224.   arelent relent;
  225.   struct   relent_chain *next;
  226. } arelent_chain;
  227.  
  228. /*
  229.  
  230. If an output_bfd is supplied to this function the generated image
  231. will be relocatable, the relocations are copied to the output file
  232. after they have been changed to reflect the new state of the world.
  233. There are two ways of reflecting the results of partial linkage in an
  234. output file; by modifying the output data in place, and by modifying
  235. the relocation record. Some native formats (eg basic a.out and basic
  236. coff) have no way of specifying an addend in the relocation type, so
  237. the addend has to go in the output data.  This is no big deal since in
  238. these formats the output data slot will always be big enough for the
  239. addend. Complex reloc types with addends were invented to solve just
  240. this problem.
  241. */
  242.  PROTO(bfd_reloc_status_enum_type,
  243.                 bfd_perform_relocation,
  244.                         (bfd * abfd,
  245.                         arelent *reloc_entry,
  246.                         PTR data,
  247.                         asection *input_section,
  248.                         bfd *output_bfd));
  249.  
  250. /*
  251. */
  252.